<template>
    <div class="box pic">
        <a-collapse ghost>
            <a-collapse-panel header="垫图图片 （0 - 3 张）">
                <div class="tips">
                    如需垫图请至少上传一张图片，图片总大小上限20M
                    <div>严禁上传违规图（政治人物、色情、暴恐等）违者100%封号</div>
                </div>
                <a-upload v-model:file-list="imgList" list-type="picture-card" :before-upload="beforeUpload" @change="onChange" @preview="handlePreview">
                    <div v-if="imgList.length < 3">
                        <plus-outlined />
                    </div>
                </a-upload>
            </a-collapse-panel>
        </a-collapse>
    </div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { getBase64 } from "@/utils";

const imgList = ref<{ originFileObj: File }[]>([]);
const emits = defineEmits(["change"]);
const beforeUpload = async () => {
    return false;
};
const onChange = async () => {
    const base64Array: string[] = [];
    for (let item of imgList.value) {
        base64Array.push(await getBase64(item.originFileObj));
    }
    emits("change", base64Array);
};
const handlePreview = () => {};
</script>
